package tut.designParttern.design.flyweight.source;

import java.util.HashMap;

public class GraphicCharFactory {
	HashMap<String, GraphicChar> pool = new HashMap<String, GraphicChar>(); // the
																			// Flyweights

	public int getNum() {
		return pool.size();
	}

	public GraphicChar get(Character c, String fontFace) {
		GraphicChar gc;
		String key = c.toString() + fontFace;
		if ((gc = pool.get(key)) != null) {
			return gc;
		} else {
			gc = new GraphicChar(c, fontFace);
			pool.put(key, gc);
			return gc;
		}
	}
}
